function xdata=lagmat(xvec,plag);
% function xdata=lagmat(xvec,plag);
% LAGMAT 
% Given a TxN matrix create a (T)xNxP matrix with the lags of 
% xvec , the original data and row of zeros at the top
% see also mlag.m where original data not included 
[T,N]=size(xvec); 
xdata=zeros(T,N*(plag+1)); 
ii=1; 
if plag==0; 
    xdata=xvec; 
elseif plag>0; 
    for ii=1:plag; 
        xdata(plag+1:end,N*ii+1:(ii+1)*N)=...
            xvec(plag+1-ii:T-ii,:); 
    end; 
end; 
xdata(plag+1:end,1:N)=xvec(plag+1:end,:); 
